﻿using System;

namespace JinianNet.Web
{
    public class HttpRunInfo
    {
        /// <summary>
        /// 获取网站根目录
        /// </summary>
        public static string AppDomainAppPath
        {
            get { return System.Web.HttpRuntime.AppDomainAppPath; }
        }

        /// <summary>
        /// 获取网站虚拟目录
        /// </summary>
        public static string AppDomainAppVirtualPath
        {
            get { return System.Web.HttpRuntime.AppDomainAppVirtualPath; }
        }

        private static string siteVirtualPath;
        public static string SiteVirtualPath
        {
            get
            {
                if (string.IsNullOrEmpty(siteVirtualPath))
                {
                    siteVirtualPath = System.Configuration.ConfigurationManager.AppSettings["SiteDirectory"];
                    if (string.IsNullOrEmpty(siteVirtualPath))
                        siteVirtualPath = AppDomainAppVirtualPath;
                    else
                        siteVirtualPath = Common.Url.Concat(AppDomainAppVirtualPath,AppDomainAppVirtualPath);
                }
                return siteVirtualPath;
            }
        }

        private static string sitePath;
        public static string SitePath
        {
            get
            {
                if (string.IsNullOrEmpty(sitePath))
                {
                    sitePath = JinianNet.Common.Path.Concat(AppDomainAppPath, SiteVirtualPath);
                }
                return sitePath;
            }

        }
    }
}
